//
// CompressedResource.h
//

#ifndef __COMPRESSED_RESOURCE_H__
#define __COMPRESSED_RESOURCE_H__

#include "SevenHeader.h"

class CCompressedResource
{
public:
	CCompressedResource(void) : _pArchive(NULL) { InitializeCriticalSection(&cs); } ;
	~CCompressedResource(void) { DeleteCriticalSection(&cs); close(); } ;

	bool open(const wchar_t *pwszFileName);
	void close(void);
	inline void lock(void) { EnterCriticalSection(&cs); }
	inline void unlock(void) { LeaveCriticalSection(&cs); }

	bool locateFile(const wchar_t *pwszFileName);
	size_t getSize(const wchar_t *pwszLocation);
	size_t getCurrentFileSize(void);
	int fetch(const wchar_t *pwszLocation, BYTE *pBuffer, size_t uBufferSize);
	int fetchCurrentFile(BYTE *pBuffer, size_t uBufferSize);

private:
	unzFile _pArchive;
	CRITICAL_SECTION cs;
};

#endif // __COMPRESSED_RESOURCE_H__
